{extend name="public:layout" /}
{block name="title"}付款单记录{/block}
{block name="head"}
<style>
    #statics{font-size:18px;margin-left:8px;}
</style>
{/block}
{block name="body"}
<div class="wrapper wrapper-content">
    <div class="ibox">
        <div class="ibox-title">
            <ol class="breadcrumb">
                <ol class="breadcrumb">
                    <li class="active"><i class="fa fa-hand-o-right"></i> 付款单记录</li>
                </ol>
            </ol>
        </div>
        <div class="ibox-content">
            <div class="toolbar">
                <form class="form-inline" id="searchForm" method="post">
                    <div class="form-group">
                        <div class="input-group">
                            <input class="form-control" type="text" placeholder="行程单检索" id="order_title" />
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="input-group">
                            <input class="form-control" type="text" placeholder="请输入车牌号" id="car_sn" />
                        </div>
                    </div>
                    <div class="form-group">
                        <input class="form-control" id="rang_time" type="text" value="" placeholder="日期范围">
                    </div>
                    <div class="form-group">
                        <div class="input-group">
                            <input class="form-control" type="text" placeholder="操作人" id="action_name" />
                        </div>
                    </div>
                    <button type="button" class="btn btn-info" onclick="refresh()"><i class="fa fa-search"></i> 搜索</button>
                    <a class="btn btn-white" href="{:url('index',['mid'=>$Request.param.mid])}">
                        <i class="fa fa-trash"></i> 清空
                    </a>
                </form>
            </div>
            <div id="buttons">
                <span class="text-danger" id="statics"> </span>
            </div>
            <table class="table table-bordered" id="grid"></table>
        </div>
    </div>
</div>
{/block}
{block name="script"}
<script type="text/javascript">
    $(function () {
        //检索日期
        In('laydate',function () {
            laydate.render({
                elem: '#rang_time',
                range: '~'
            });
        });
        //列定义
        var columnsData=[
            {field: 'pay_id', title: '编号',width:60,sortable:true},
            {field: 'car_sn', title: '车辆'},
            {field: 'order_title', title: '行程单',sortable:true},
            {field: 'pay_money', title: '收款金额',sortable:true,
                footerFormatter: function (value) {
                    var count = 0;
                    for (var i in value) {
                        count += parseFloat(value[i].pay_money);
                    }
                    return count.toFixed(2);
                }
            },
            {field: 'money_bala', title: '结余费用',sortable:true,
                footerFormatter: function (value) {
                    var count = 0;
                    for (var i in value) {
                        count += parseFloat(value[i].money_bala);
                    }
                    return count.toFixed(2);
                }
            },
            {field: 'money_discount', title: '优惠费用',sortable:true,
                footerFormatter: function (value) {
                    var count = 0;
                    for (var i in value) {
                        count += parseFloat(value[i].money_discount);
                    }
                    return count.toFixed(2);
                }
            },
            {field: 'demo_money', title: '现金(参考)',
                formatter:function (value,row,index) {
                    if(row.money_bala!=0){
                        return row.money_bala;
                    }else{
                        return row.pay_money;
                    }
                },
                footerFormatter: function (value) {
                    var count = 0;
                    for (var i in value) {
                        if(value[i].money_bala!=0){
                            count += parseFloat(value[i].money_bala);
                        }else{
                            count += parseFloat(value[i].pay_money);
                        }
                    }
                    return count.toFixed(2);
                }
            },
            {field: 'pay_time', title: '收款时间',sortable:true},
            {field: 'action_name', title: '操作人'}
        ];
        In('btable', function () {
            $('#grid').bootstrapTable({
                showColumns:true,
                toolbar:'#buttons',
                url: '__URL__/pagelist.html',
                sortName:'pay_id',
                sortOrder:'desc',
                method:'post',
                pagination:true,
                queryParamsType:'page',
                sidePagination:'server',
                pageSize:60, //每页记录数
                showRefresh:true, //显示刷新按钮
                showToggle:true, //显示切换视图按钮
                showPaginationSwitch:true, //显示数据条数选择框
                idField:'pay_id', //主键列
                clickToSelect:true, //设置true 将在点击行时，自动选择rediobox 和 checkbox
                singleSelect:false, //设置true 将禁止多选
                maintainSelected:true, //设置为true 将记住选择项
                queryParams:function (params) {
                    params.car_sn=$("#car_sn").val();
                    params.rang_time=$("#rang_time").val();
                    params.action_name=$("#action_name").val();
                    params.order_title=$("#order_title").val();
                    return params;
                },
                /*
                onLoadSuccess:function (data) {
                    var date=$("#rang_time").val();
                    var static=data.static;
                    if(date!=''){
                        date = '['+date+']';
                    }
                    var html=date;
                    if(static.total_pay_money>0){
                        html+=' 共收款：'+static.total_pay_money+'元';
                    }
                    if(static.total_money_bala>0){
                        html+=' 共结余：'+static.total_money_bala+'元';
                    }
                    if(static.total_money_discount>0){
                        html+=' 共优惠：'+static.total_money_discount+'元';
                    }
                    $('#statics').text(html);
                },
                */
                columns: columnsData,
                showFooter: true
            });
        });
    });
    //刷新表格
    function refresh() {
        $('#grid').bootstrapTable('refresh');
    }
</script>
{/block}